I have a word export DXL script that I have been modifying for use in our specific project. I believe I have found the line of code that sets the heading style (in Word) based off of the object level in the DOORS module being exported. The modules were imported with paragraph style, and we have the correct object level's for each object. Here is a snip of the code:
FUNCTION: computeStyleName
PURPOSE: Computes the style name for the passed object/attribute
PARAMETERS: Object obj - object to compute style name for
string attName - name of attribute to compute style name for
RETURNS: string styleName - computed style name
------------------------------------------------------------------------------*/
string computeStyleName(Object obj, string attName)
{
string styleName
if (find(skSTYLE_NAME_BY_ATT_NAME, attName, styleName))
{
return styleName
}
if (attName == sATTR_OBJECT_HEADING)
{
int iLevel = (level obj)
if(iLevel > 9) iLevel = 9
return "Heading " iLevel ""
}
return "Normal"
}
I am new to DXL and programming, so not sure if I have found the right function or not. It seems to have the correct inputs, and outputs for relating object level with heading style. The output of this function gives us our headings with their object numbers as desired. What we want, is to also apply object numbers to the object text. i.e. 1.1 System Interface 1.1.1 The system interfaces shall..... The function only recognizes object headings and applies the styling to them, and cannot identify object text (line 17?). I tried modifying the function to identify object text. Here is a snip of my current edit:
string computeStyleName(Object obj, string attName)
{
string styleName
if (find(skSTYLE_NAME_BY_ATT_NAME, attName, styleName))
{
return styleName
}
if (attName == sATTR_OBJECT_HEADING)
{
int iLevel = (level obj)
if (iLevel > 9) iLevel = 9
return "Heading " iLevel ""
} else if (attName == sATTR_OBJECT_TEXT)
{
int iLevel = (level obj)
return "Heading " iLevel ""
} else
{
return "Normal"
}
}
Not sure if my approach is correct. Should I write an entirely new function for this task? Are my constraints within the 'else if' incorrect? Any help or ideas are appreciated; thanks! Currently the function still only outputs the heading objects with heading numbers in the word doc. dxlnewb - Mon Jun 11 17:03:30 EDT 2018 |
Re: Set Heading Style During Word Export This seems like an odd way to apply styles. None the less... I assume sATTR_OBJECT_HEADING and sATTR_OBJECT_TEXT are correctly defined ("Object Heading" and "Object Text" respectively). If so, the next question is how do you know there is not an entry for "Object Text" in the skSTYLE_NAME_BY_ATT_NAME skip list? If there is, it would override your later code that tries to set it based on object level. Otherwise, your function looks like it will correctly set the style for Object Text to "Heading <n>" where <n> is the object level. So in that case, you would have to check how the style value returned by the function is being used to set the Word style ... that part may not be working correctly. If it was, the styleName value returned would be used somewhere. Standard Word export script does it like this inside void wordDumpBodyVBA(Object o):
string errMess Buffer textBuffer = create textBuffer = richTextWithOleNoCache o.OutputAttr
errMess = applyStyleLockPasteInvoke(objSel, textBuffer, pstyle, containsOle(o.OutputAttr)) //pstyle would be value of styleName from your function |